package com.victor.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.victor.entity.step.JMInfo;
import com.victor.entity.step.JMPhoto;
import com.victor.entity.user.User;
import com.victor.entity.user.UserFeedback;
import com.victor.entity.user.UserFeedbackClass;
import com.victor.entity.user.UserFeedbackPhoto;

@Mapper
public interface MyselfDao {

	/**
	 * 修改用户信息
	 */
	Integer updateUser(User user);

	/**
	 * 提交加盟信息
	 */
	boolean submitJMInfo(JMInfo jmInfo);

	/**
	 * 提交加盟营业执照，身份证，经营许可证，环境等相关照片
	 */
	boolean submitPhoto(JMPhoto photos);

	/**
	 * 提交反馈信息
	 */
	boolean addfeedback(UserFeedback userFeedback);

	@Insert({ "insert into user_feedback_photo (feedbackid,photo) values(#{feedbackid},#{photo})" })
	boolean addfeedbackPhoto(UserFeedbackPhoto userFeedbackPhoto);

	/**
	 * 添加反馈类型
	 * 
	 * @param userFeedbackClass
	 * @return
	 */
	@Insert({ "insert into user_feedback_class (classname) values(#{classname})" })
	boolean addBackClass(UserFeedbackClass userFeedbackClass);

	/**
	 * 后台删除反馈类型
	 * 
	 * @param id
	 * @return
	 */
	@Delete({ "delete from user_feedback_class where id=#{id}" })
	boolean delBackClassById(Integer id);

	/**
	 * 根据类型id删除反馈表中信息
	 * 
	 * @param id
	 * @return
	 */
	@Delete({ "delete from user_feedback where classid=#{id}" })
	boolean delBackByClassId(Integer id);

	/**
	 * 根据图片表中feedbackid 删除图片
	 * 
	 * @param i
	 * @return
	 */
	@Delete({ "delete from user_feedback_photo where feedbackid=#{feedbackid}" })
	boolean delPhotoByClassId(String feedbackid);

	/**
	 * 根据反馈类型id查询id
	 * 
	 * @param id
	 * @return
	 */
	@Select({ "select id from user_feedback where classid=#{id}" })
	List<Integer> selIdByClassId(String id);

	/**
	 * 根据传入UserFeedback字段查询列表
	 * 
	 * @param userFeedback
	 * @return
	 */
	List<UserFeedback> selectBack(UserFeedback userFeedback);

	/**
	 * 后台回复反馈信息
	 * 
	 * @param id
	 * @param replyid
	 * @param replymessage
	 * @return
	 */
	boolean replyFeedback(Integer id, String replyid, String replymessage);

	/**
	 * 根据反馈类型id批量删除反馈信息
	 * 
	 * @param ids
	 * @return
	 */
	boolean batchDelete(@Param("ids") int[] ids);

	/**
	 * 删除反馈图片
	 * 
	 * @param ids
	 * @return
	 */
	boolean deletePhoto(@Param("ids") int[] ids);

	/**
	 * 根据id获取用户原密码
	 */
	@Select({ "select * from `user` where id=#{id}" })
	User getUserById(Integer id);

	/**
	 * 通过userid查询该用户是否已经实名认证
	 * 
	 * @param userid
	 * @return
	 */
	@Select({ "select certification from user where id=#{userid}" })
	Integer ifCertification(@Param("userid") Integer userid);
}
